Logical expressions in C yield a value of 1 (true) or 0 (false). For example:
result = 5 > 6;
Since the assignment operator '=' has very low precedence, the logical expression '5>6' is evaluated first, and the value 0 (false) is assigned to the integer variable 'result'. To distinguish it from the assignment operator, the logical operator for equality uses two equal signs: '=='. A VERY COMMON PROGRAMMING ERROR IS TO USE THE ASSIGNMENT OPERATOR WHERE THE EQUALITY OPERATOR WAS INTENDED. For example, the programmer expected the condition in the following 'if' statement to be true, since the value of 'a == 0' would be 1. However, since the value of an assignment expression is the value which was assigned, the value of 'a = 0' is 0 and the condition is false. Note that the expression is still legal, so no compilation error is generated.